package org.commons;

import java.net.HttpURLConnection;
import java.net.URL;

public class HTTPUtils {
	
	public static boolean exists(URL url){
	    try {
	      HttpURLConnection.setFollowRedirects(false);
	      // note : you may also need
	      //        HttpURLConnection.setInstanceFollowRedirects(false)
	      HttpURLConnection con =
	         (HttpURLConnection) url.openConnection();
	      con.setRequestMethod("HEAD");
	      return (con.getResponseCode() == HttpURLConnection.HTTP_OK);
	    }
	    catch (Exception e) {
	    //   e.printStackTrace();
	       return false;
	    }
	  }
}
